using System;
using System.Linq.Expressions;

namespace TrueCode.Core
{
  public static class nameof
  {
    public static string Property< TV >( Expression< Func< TV > > property )
    {
      var body = property.Body as MemberExpression;
        if(body == null)
            throw new ArgumentException("'expression' should be a member expression");
        return body.Member.Name;
    }
  }

  public static class nameof< T >
  {
    public static string Property< TV >( Expression< Func< T, TV > > property )
    {
       var body = property.Body as MemberExpression;
        if(body == null)
            throw new ArgumentException("'expression' should be a member expression");
        return body.Member.Name;
    }
  }
}